//
//  SISSDrafsCell.m
//  SISSAPP
//
//  Created by 优房网 on 2017/9/8.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSDrafsCell.h"
#import "SISSSellerEntrustContractModel.h"
#import "SISSBuyerEntrustContractDraftModel.h"
#import "SISSLeaserEntrustContractModel.h"
#import "SISSTenantEntrustContractModel.h"

@interface SISSDrafsCell ()

/// 姓名Label
@property (weak, nonatomic) UILabel *nameLabel;
/// 保存时间Label
@property (weak, nonatomic) UILabel *timeLabel;

/// 底部线条view
@property (weak, nonatomic) UIView *lineView;

@end
@implementation SISSDrafsCell

- (void)setSellerEntrustModel:(SISSSellerEntrustContractModel *)sellerEntrustModel {
    _sellerEntrustModel = sellerEntrustModel;
    
    self.nameLabel.text = sellerEntrustModel.sellerName ? sellerEntrustModel.sellerName : @"";
    self.timeLabel.text = [sellerEntrustModel.insertTime substringToIndex:10];
}

- (void)setBuyerEntrustDraftModel:(SISSBuyerEntrustContractDraftModel *)buyerEntrustDraftModel {
    _buyerEntrustDraftModel = buyerEntrustDraftModel;
    
    self.nameLabel.text = buyerEntrustDraftModel.buyerName;
    self.timeLabel.text = [buyerEntrustDraftModel.insertTime substringToIndex:10];
}

- (void)setLeaserEntrustDraftModel:(SISSLeaserEntrustContractModel *)leaserEntrustDraftModel {
    _leaserEntrustDraftModel = leaserEntrustDraftModel;
    
    self.nameLabel.text = leaserEntrustDraftModel.landlordName;
    self.timeLabel.text = [leaserEntrustDraftModel.insertTime substringToIndex:10];
}

- (void)setTenantEntrustDraftModel:(SISSTenantEntrustContractModel *)tenantEntrustDraftModel {
    _tenantEntrustDraftModel = tenantEntrustDraftModel;
    
    self.nameLabel.text = tenantEntrustDraftModel.renterName;
    self.timeLabel.text = [tenantEntrustDraftModel.insertTime substringToIndex:10];
}



#pragma mark - UI
- (void)initUI {
    [super initUI];
    
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = @"姓名";
    nameLabel.textColor = COLOR(0x8998A5);
    nameLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:nameLabel];
    self.nameLabel = nameLabel;

    
    UILabel *timeLabel = [[UILabel alloc] init];
    timeLabel.text = @"2017-7-24 09:37";
    timeLabel.textColor = COLOR(0x8998A5);
    timeLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:timeLabel];
    self.timeLabel = timeLabel;
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.contentView addSubview:lineView];
    self.lineView = lineView;
}

#pragma mark - 约束
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGFloat margin = 8.0;
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView).offset(margin);
        make.top.equalTo(weakSelf.contentView).offset(margin);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.nameLabel);
        make.top.equalTo(weakSelf.nameLabel.mas_bottom).offset(2 * margin);
        make.bottom.equalTo(weakSelf.lineView).offset(- margin);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(weakSelf.contentView);
        make.height.mas_equalTo(1);
    }];
    
}


@end
